<extend name="template/base_index" />

<block name="area_header">
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.3/css/select2.min.css" />
    <link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/cosmo-skin.css" />
    <style type="text/css">
    </style>
    <script type="text/javascript" src="__CDN__/jquery-validation/1.13.1/jquery.validate.min.js"></script>
    <script type="text/javascript" src="__CDN__/jquery-validation/1.13.1/localization/messages_zh.min.js"></script>
</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}
            <div class="h4">提现审核 - 操作待处理</div>

            <div class="filter-controls">
                <form class="form-inline searchForm" method="post" action="{:U('Admin/Withdraw/verify')}">
                <div class="form-group row">
                    <div class="input-group">
                        <div class="input-group-addon"><i class="fa fa-user"></i>提现用户</div>
                        <select id="user_select2" name="uid" class="form-control">
                            <if condition="$uid gt 0"><option value="{$uid}" selected="selected">[id:{$uid}] {$nick}</option></if>
                        </select>

                    </div>&nbsp;
                    <button class="btn btn-sm btn-primary" type="submit">查询</button>&nbsp;
                    <div class="form-group">
                    <label>状态</label>
                    <select class="form-control input-short input-sm select_status" name="valid_status">
                        <option class="valid_status" value="-2">全部</option>
                        <option class="valid_status" value="1">打款</option>
                        <option class="valid_status" value="0">待处理</option>
                        <option class="valid_status" value="2">驳回</option>
                    </select>
                    </div>
                </div>
                <!-- <div class="form-group"></div> -->
                </form>
            </div>

            <div class="table-responsive">
                <table class="table table-bordered table-striped table-condensed table-hover table-condensed">
                <thead>
                     <th>ID</th>
                     <th>用户ID</th>
                     <th>申请详情</th>
                     <th>申请提现金额</th>
                     <th>申请时间</th>
                     <th>最近一次客服回复</th>
                     <th>状态</th>
                     <th>操作</th>
                </thead>
                <tbody>
                <volist name="list" id="vo">
                <tr>
                	<td>{$vo.id}</td>
                    <td><a href="{:U('Admin/CustomerInfo/index',array('id'=>$vo['uid']))}">{$vo.uid}</a></td>
                    <td>{$vo.reason}</td>
                    <td>{$vo.money}</td>
                    <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                    <td>{$vo.reply_msg}</td>
                    <td><if condition="$vo.valid_status eq 0"><font color="pink">待处理</font><elseif condition="$vo.valid_status eq 1" />已处理-打款<elseif condition="$vo.valid_status eq 2" />已处理-驳回<else />未知</if></td>
                    <td>
                        <a href="{:U('Admin/Withdraw/pass',array('id'=>$vo['id']))}" class="btn btn-warning btn-sm ajax-get confirm"><i class="fa fa-check"></i>已打款</a>
                        <button class="btn btn-primary btn-sm" type="button" data-toggle="modal" data-orderid="{$vo.id}" data-target="#cancelModel"><i class="fa fa-reply"></i>驳回</button>
                       <!--  <a class="btn btn-sm btn-danger" href="{:U('Admin/Withdraw/deny',array('id'=>$vo['id']))}"><i class="fa fa-times"></i>驳回</a> -->
                    </td>
                </tr>
                </volist>
                </tbody>
                </table>
                <div>{$show}</div>
            </div>

        </div>
        <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->

    <div class="modal fade" id="cancelModel" tabindex="-1" role="dialog" aria-labelledby="cancelModelLabel" aria-hidden="true">
      <div class="modal-dialog" style="z-index: 12345678;">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">驳回原因</h4>
          </div>
          <div class="modal-body">
            <form class="denyForm" id="denyForm" action="{:U('Admin/Withdraw/deny')}">
              <input type="hidden" name="id" id="id" value="" />
              <div class="form-group">
                <label for="message-text" class="control-label">原因:</label>
                <textarea class="form-control required" rows="5" name="reason" id="message-text"></textarea>
              </div>
            </form>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-close"></i>关闭</button>
            <button type="button" url="{:U('Admin/Withdraw/deny')}" target-form="denyForm" class="ajax-post btn btn-primary"><i class="fa fa-save"></i>保存</button>
          </div>
        </div>
      </div>
    </div>
</block>

<block name="area_footer">
    <script src="__CDN__/select2/4.0.3/js/select2.min.js"></script>
    <script src="__CDN__/select2/4.0.3/js/i18n/zh-CN.js"></script>

    <script type="text/javascript">
        $(function(){
            $('.select_status').val({$valid_status});
            $("select[name='valid_status']").change(function(){
                $('.searchForm').submit();
            });
        });
    </script>

    <script type="text/javascript">
        $('#cancelModel').on('show.bs.modal', function (event) {
          var button  = $(event.relatedTarget); // Button that triggered the modal
          var orderid = button.data('orderid'); // Extract info from data-* attributes
          var modal   = $(this);
          // modal.find('.modal-title').text('New message to ' + recipient);
          modal.find('.modal-body #id').val(orderid);
        });
        $(function(){
            $("#denyForm").validate();
            $select2 = $("#user_select2").select2({
                placeholder: "输入用户id或昵称查询"	,
                language: "zh-CN",
                ajax: {
                    url: "{:U('Admin/Member/select')}",
                    dataType: 'json',
                    width: 250,
                    delay: 250,
                    data: function (params) {
                        var queryParameters = {
                            q: params.term
                        }
                        return queryParameters;
                    },
                    processResults: function (data, params) {
                        if(!data.info){
                            data.info = new Array();
                            data.info['nodata']="无相关数据";
                        }
                        // parse the results into the format expected by Select2.
                        // since we are using custom formatting functions we do not need to
                        // alter the remote JSON data
                        return {
                            results: data.info
                        };
                    },
                    cache: true
                },
                minimumInputLength: 0,
                templateSelection: function (repo) {
                    return repo.nickname ? '[id:'+repo.id+'] '+repo.nickname : repo.text;
                },
                templateResult: function (repo) {
                    if (repo.loading) return repo.text;
                    if(repo.nodata) return repo.nodata;
//    				var markup = '<div>'+repo.nickname+'</div>';
                    var markup = '<div><img src="'+repo.head+'" style="width:30px;height:30px;"/>[id:'+repo.id+'] '+repo.nickname+'</div>';
                    return $(markup);
                },
            });
        });
    </script>
</block>